<?php

namespace app\common\model\supplier;

use app\common\model\BaseModel;

class SupplierCommissionWithdrawal extends BaseModel
{


    public static function createData($data)
    {
        $data['app_id'] = self::$app_id;
        return self::create($data);
    }

    public static function getWithdrawalList($params)
    {
        $shop_supplier_id = $params['shop_supplier_id'];
        if($shop_supplier_id){
            $map[] = ['shop_supplier_id','=',$shop_supplier_id];
        }
        $list = self::where($map) -> field('*')-> order('commission_withdrawal_id desc') -> with(['supplier','admin']) ->paginate($params);
        return $list;
    }

    /**
     * 关联供应商表
     */
    public function supplier()
    {
        return $this->belongsTo('app\\common\\model\\supplier\\Supplier', 'shop_supplier_id', 'shop_supplier_id')
            ->bind(['name']);
    }

    /**
     * 关联供应商表
     */
    public function admin()
    {
        return $this->belongsTo('app\\common\\model\\shop\\User', 'shop_user_id', 'shop_user_id')
            ->bind(['user_name']);
    }

    /**
     * 待审核数量
     * getAuditCount
     * int
     * @return int
     * @throws \think\db\exception\DbException
     * static
     * @throws \think\db\exception\DbException
     * @Author kevin
     * @date 2024/5/20 10:35
     */
    public static function getAuditCount(){
        $map = [];
        $map[] = ['status','=',0];
        return self::where($map) -> count();

    }


}